Repository navigation
wifi_manager: keep Wi-Fi awake with Bluetooth on, as without - #856
Merged
Merged
Conversation
A board on a cable now turns power saving off whether or not Bluetooth is running. ESP-IDF's coexistence gives Wi-Fi and Bluetooth their own time slices either way, and leaving Wi-Fi asleep made a Bluetooth speaker's own page and WebREPL slow or unreachable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wifi_manager.connect()turns Wi-Fi power saving off on a board with no battery, but it made an exception while Bluetooth runs, on the idea that Bluetooth needs Wi-Fi asleep to share the antenna. It doesn't: ESP-IDF's coexistence gives Wi-Fi and Bluetooth their own time slices, and with power saving off Wi-Fi still sleeps outside its own slice (ESP-IDF's Wi-Fi guide, under Modem-sleep). The exception kept a Bluetooth speaker's Wi-Fi asleep, so its own pages and WebREPL were slow or unreachable. This drops it.power_save()andset_power_save()are unchanged, and a rememberedset_power_save(True)or a fitted battery still keeps power saving on.On an Ai-Thinker ESP32 Audio Kit (classic ESP32, 4 MB) running Bluetooth Receiver with its screen served by
RemoteDisplay, at -44 to -54 dBm, after a hard reset and 40 s idle, then a page load every 35 s from Windows and from Linux and 30 pings:The open question was whether keeping Wi-Fi awake costs Bluetooth audio. A computer streamed a quiet 440 Hz tone to the board over A2DP (SBC, 48 kHz) for about 200 s in each mode, with the app's screen, the spectrum and the remote display running. With power saving on and with it off, the sink's counters showed no underruns, overruns, dropped, repeated or skipped frames, the audio pump never ran dry, and frames arrived at 48.0k a second. Four 0.9 s captures of the pump's output in each mode, taken with
audiopump.Tap, are clean sines with no phase breaks.tests/test_wifi_manager.pynow has Bluetooth Classic and BLE both on and expects the station awake; it fails on main and passes here (66 Wi-Fi tests pass). Not checked: BLE on an S3 or C3 (the S31 had kept its link with BLE on and power saving off), CircuitPython on a board, and the page while music plays. During a stream the bench computer was itself the Bluetooth source, and its own Wi-Fi then lost 40% of its pings to the router, so the board's Wi-Fi during playback couldn't be judged from it.